<template>
  <el-container class="home-container">
    <el-header>
      <div>
        <p>民大商城</p>
      </div>
      <el-button type="primary" @click="logout">退出</el-button>
    </el-header>
    <el-container>
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggle">|||</div>
        <el-menu
          router :default-active="$route.path"
          class="el-menu-vertical-demo"
          background-color="#B3C0D1" unique-opened
          :collapse="isCollapse"
          :collapse-transition="false"
          @open="handleOpen"
          @close="handleClose"
        >
          <el-menu-item index="/welcome">
            <template slot="title">
              <i class="el-icon-house"></i>
              <span slot="title">主页</span>
            </template>
          </el-menu-item>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-shopping-cart-2"></i>
              <span slot="title">商城</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/goods">商品</el-menu-item>
              <el-menu-item index="/address">查看订单</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data () {
    return {
      isCollapse: false
    }
  },
  methods: {
    logout () {
      this.$router.push('/login')
    },
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    },
    toggle () {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style>
.home-container{
  height:50%;
  width: 50%;
}
.toggle-button {
  background-color: #4A5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}

</style>
